package com.xiaoy.core.base.security.permissions.entity;

import java.util.List;

import com.xiaoy.core.base.security.org.entity.Org;
import com.xiaoy.core.base.security.role.entity.Role;
import com.xiaoy.core.base.security.user.entity.User;
/**
 * 
 * @author chentianyi
 * 2014-3-24 上午9:20:29
 * TODO
 *
 */
public class SessionFacade {

	private static ThreadLocal<SessionFacade> userData = new ThreadLocal<SessionFacade>();

	/**
	 * 所有的角色
	 */
	private List<Role> roles = null;

	/**
	 * 当前用户
	 */
	private User currentUser;

	/**
	 * 所属的机构
	 */
	private Org org = null;

	public static SessionFacade get() {
		SessionFacade ex = (SessionFacade) userData.get();

		if (ex == null) {
			ex = new SessionFacade();
			userData.set(ex);
		}
		return ex;
	}

	public static void set(SessionFacade ex) {
		userData.set(ex);
	}

	public static boolean exists() {
		return (userData.get() != null);
	}

	public List<Role> getRoles() {
		return roles;
	}

	public void setRoles(List<Role> roles) {
		this.roles = roles;
	}

	public User getCurrentUser() {
		return currentUser;
	}

	public void setCurrentUser(User currentUser) {
		this.currentUser = currentUser;
	}

	public Org getOrg() {
		return org;
	}

	public void setOrg(Org org) {
		this.org = org;
	}

	
}
